from pandac.PandaModules import *

class MapLoader:
    """description of class"""
    
    def loadMap(self, filename):
        self.heightMap = PNMImage()
        self.heightMap.read(Filename(filename))
        self.x = self.heightMap.getXSize()
        self.y = self.heightMap.getYSize()


    
    def createTerrain(self, filename, node):
        self.terrain = GeoMipTerrain("Terrain")
        self.terrain.setHeightfield(filename)

        # terrain proporties
        self.terrain.setBlockSize(32)
        self.terrain.setNear(20)
        self.terrain.setFar(40)
        self.terrain.setFocalPoint(base.camera)

        self.root = self.terrain.getRoot()
        self.root.reparentTo(node)
        self.root.setSz(100)

        self.terrain.generate()

    def updateTask(self, task):
        self.terrain.update()
        return task.cont

    def loadHex(self, filepath, node):
        pass 